/**
 * Copyright (c) 2019 xstgongyi.org
 * All rights reserved.
 */
package org.xstgongyi.eduaid.service;

import java.time.LocalDateTime;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xstgongyi.eduaid.dataobject.GradeDO;
import org.xstgongyi.eduaid.manager.GradeManager;

/**
 * @author oldcrane<br/>
 * @created 2019-04-14
 */
@Service
public class GradeServiceImpl implements GradeService {

	@Autowired
	private GradeManager gradeManager;

	@Override
	public void insert(GradeDO grade) {
		LocalDateTime now = LocalDateTime.now();
		grade.setGmtCreated(now);
		grade.setGmtUpdated(now);
		gradeManager.insert(grade);
	}

	@Override
	public void update(GradeDO grade) {
		grade.setGmtUpdated(LocalDateTime.now());
		gradeManager.update(grade);
	}

	@Override
	public List<GradeDO> listAll() {
		return gradeManager.listAll();
	}

	@Override
	public List<GradeDO> listByStatus(Boolean active) {
		return gradeManager.listByStatus(active);
	}

	@Override
	public GradeDO getById(Integer id) {
		GradeDO grade = (null == id ? null : gradeManager.getById(id));
		return grade;
	}

}
